package hustlas.ball.preparse;

import java.util.HashMap;


/**
 * The tokens for TINY, could be swapped for a same named enum with token
 * names for another language
 * 
 * @author Steven
 *
 */
public enum Tokens {
    
	/*TODO: Add values from 0-whatever for the tokens to allow O(1) checking
	 * if a token is valid
	 */
	BEGIN, 
	END, 
	PRINT, 
	LEFTPAR, 
	RIGHTPAR, 
	SEMICOLON, 
	ID, 
	ASSIGN, 
	READ, 
	COMMA, 
	INTNUM, 
	PLUS, 
	MINUS, 
	MULTIPLY, 
	MODULO,
	$,
	ϵ;
	
	private static HashMap<String, Tokens> map;
public static void makeEnumMap(){
    map = new HashMap<String, Tokens>();
    map.put("BEGIN", Tokens.BEGIN);
    map.put("END", Tokens.END);
    map.put("PRINT", Tokens.PRINT);
    map.put("LEFTPAR", Tokens.LEFTPAR);
    map.put("RIGHTPAR", Tokens.RIGHTPAR);
    map.put("SEMICOLON", Tokens.SEMICOLON);
    map.put("ID", Tokens.ID);
    map.put("ASSIGN", Tokens.ASSIGN);
    map.put("READ", Tokens.READ);
    map.put("COMMA", Tokens.COMMA);
    map.put("INTNUM", Tokens.INTNUM);
    map.put("PLUS", Tokens.PLUS);
    map.put("MINUS", Tokens.MINUS);
    map.put("MULTIPLY", Tokens.MULTIPLY);
    map.put("MODULO", Tokens.MODULO);
}

public static Tokens getToken(String stringToken){
    return map.get(stringToken);
}
}